package etxt2db.serialization;
import java.io.*;

import etxt2db.api.ClassificationModel;


public class ClassificationModelSerializer {
	public void serializeClassificationModel(ClassificationModel annot,String path){
		 try {
			 // Serialize to a file
		     ObjectOutput out = new ObjectOutputStream(new FileOutputStream(path));
		     out.writeObject(annot);
		     out.close();
		    
		     // Serialize to a byte array
		     //ByteArrayOutputStream bos = new ByteArrayOutputStream() ;
		     //out = new ObjectOutputStream(bos) ;
		     //out.writeObject(annot);
		     //out.close();
		    
		     // Get the bytes of the serialized object
		     //byte[] buf = bos.toByteArray();
		 } catch (IOException e) {
		 }
	}
	
	public ClassificationModel deserializeClassificationModel(String path){
		try {
			 File file = new File(path);
		     ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
		     // Deserialize the object
		     ClassificationModel annot = (ClassificationModel) in.readObject();
		     in.close();

		     return annot;
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}
}
